package com.sl.biz.modular.ai.controller;

import com.sl.biz.modular.ai.controller.domain.request.AiChatTemplateResolveConfigRequest;
import com.sl.biz.modular.ai.dao.domain.entity.AiChatConfigDO;
import com.sl.biz.modular.ai.service.AiChatConfigBizService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/ai/chat")
@RequiredArgsConstructor
public class AiChatConfigController {

    private final AiChatConfigBizService aiChatConfigBizService;

    @PostMapping("/get_by_ai_id")
    public AiChatConfigDO getByAiId(@RequestBody AiChatConfigDO cdcConfigDO) {
        return aiChatConfigBizService.getByAiId(cdcConfigDO);
    }


    @PostMapping("/save")
    public Boolean save(@RequestBody AiChatConfigDO cdcConfigDO) {
        return aiChatConfigBizService.save(cdcConfigDO);
    }

    @PostMapping("/resolve_template_config")
    public String resolveTemplateConfig(@RequestBody AiChatTemplateResolveConfigRequest aiChatTemplateResolveConfigRequest) {

        return aiChatConfigBizService.resolveTemplateConfig(
                aiChatTemplateResolveConfigRequest.getTemplate(),
                aiChatTemplateResolveConfigRequest.getData()
        );
    }
}
